<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('论文选题列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <input type="hidden" name="thesisType" value="2"/>
                                <label>题目名称：</label>
                                <input type="text" name="thesisName"/>
                            </li>
                            <li>
                                <label>学年：</label>
                                <input type="text" name="academicYear"/>
                            </li>
                            <li>
                                <label>教师工号：</label>
                                <input type="text" name="thesisTeacherUser.loginName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group" shiro:hasRole="student">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="thesis:title:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="thesis:title:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="thesis:title:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasRole('student')}]];
        var removeFlag = [[${@permission.hasRole('student')}]];
        var selectFlag = [[${@permission.hasPermi('thesis:title:teacherSelectThesis')}]];
        var prefix = ctx + "thesis/title";
        var datas = [[${@dict.getType('thesis_type')}]];
        var thesisStatus = [[${@dict.getType('thesis_status')}]];

        $(function() {
            var options = {
                url: prefix + "/stuList",
                createUrl: prefix + "/studentadd",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                importUrl: prefix + "/importData",
                exportUrl: prefix + "/export",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "论文选题",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'thesisId',
                    title: '*',
                    visible: false
                },
                {
                    field: 'thesisName',
                    title: '题目名称'
                },
                {
                    field: 'thesisDesc',
                    title: '题目介绍'
                },
                {
                    field: 'thesisType',
                    title: '题目类型',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(datas, item.thesisType);
                    }
                },
                {
                    field: 'academicYear',
                    title: '学年'
                },
                {
                    field: 'thesisTeacherUser.loginName',
                    title: '指导教师'
                },
                {
                    field: 'createByName',
                    title: '创建人'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(thesisStatus, item.status);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status == '0'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.thesisId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.thesisId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            actions.push('<a class="btn btn-primary btn-xs ' + selectFlag + '" href="javascript:void(0)" onclick="teacherSelectThesis(\'' + row.thesisId + '\' )"><i class="fa fa-check"></i>导师确认</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
     <script th:inline="javascript">
         function teacherSelectThesis(thesisId) {
             $.modal.confirm("确认选择该论文题目吗？", function() {
                 var data = {
                     thesisId:thesisId
                 };
                 $.operate.post("/thesis/title/teacherSelectThesis",data);
             });
         }
     </script>
</body>
</html>